<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport"
          content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0"/>
    <meta name="format-detection" content="telephone=no"/>
    <title>商家首页</title>
    <link rel="stylesheet" type="text/css" href="../../css/aui.css"/>
    <link rel="stylesheet" type="text/css" href="../../css/common.css"/>
    <style>
        /*//头部*/
        .aui-bar {
            background: #fff;
        }

        .aui-tab-nav li.active {
            color: #327afa;
            border-bottom: 2px #327afa solid;
        }

        .iConent:before {
            content: "\e700" !important;
        }

        .aui-tab-nav li {
            font-size: 15px;
            border-bottom: 1px dotted #eee;
        }

        .aui-bar .search {
            height: 35px !important;
            margin: 5px 0 !important;
            padding-left: 35px;
            background: #f4f3f3;
            border: none;
            border-radius: 5px;
        }

        .divSeach {
            position: relative;
            width: 70% !important;
            height: 45px;
            float: left;
            margin-left: 8px;
            padding: 5px 0;
        }

        .touxiang img {
            width: 63px;
            height: 63px;
        }

        .aui-bar .aui-iconfont.aui-icon-search {
            position: absolute;
            left: 0;
            color: #b0b0ae;
            line-height: 35px;
        }

        .aui-bar .aui-iconfont {
            color: #b0b0ae;
        }

        .headerRight {
            overflow: hidden;
        }

        .headerRight i:first-of-type {
            width: 50%;
        }

        .my-info {
            width: 100%;
            position: relative;
            height: 130px;
        }

        .headerPic {
        }

        .headerPic img {
            width: 100%;
            display: inherit;
            height: 130px;
        }

        .myInfoList {
            position: absolute;
            bottom: 0;
            width: 100%;
            background: rgba(0, 0, 0, .5);
            overflow: hidden;
            height: 63px;
        }

        .myInfoList .touxiang {
            float: left;
        }

        .myInfoList ul {
            height: 100%;
        }

        .myInfoList li {
            float: left;
            height: 100%;
            text-align: left;
            font-size: 14px;

        }

        .companyName {
            line-height: 30px;
        }

        .year {
            display: block;
            line-height: 22px;
        }

        .infoLeft {
            margin-left: 10px;
            width: 36%;
        }

        .infoRight {
            margin-top: 8px;
            /*margin-right: 30px;*/
            font-size: 12px !important;
            width: 41%;
        }

        .fensi {
            float: left;
            line-height: 15px;
            width: 50px;
            text-align: center;
            margin-right: 5px;
            margin-top: 8px;
        }

        .shoucang {
            border-radius: 5px !important;
            margin-bottom: 4px;
            width: 65px !important;
            height: 30px !important;
            line-height: 30px !important;
            background-color: #3498db;
            font-size: 14px;
            height: 45px;
            line-height: 45px;
            margin: 0;
            border: none;
            cursor: pointer;
            padding: 0 !important;
            display: inline-block;
            text-align: center;
            vertical-align: middle;
        }

        #headerFooter {
            position: relative;
            line-height: 20px;
        }

        #aui-footer {
            height: 45px;
            line-height: 45px;
            font-size: 14px;
        }

        .allType {
            display: none;
        }

        .zfTitle {
            padding-left: 10px;
            font-size: 14px;
            border-left: 3px solid #327afa;
            color: #000;
            text-align: left;
        }

        .more {
            font-size: 12px !important;
        }

        .allPro, .newPro, .newInfo {
            display: none;
        }

        footer.aui-nav .aui-bar-tab p {
            font-size: 14px;
        }

        footer .aui-bar-tab li {
            position: relative;
        }

        footer .aui-bar-tab li:first-of-type:before {
            content: "";
            position: absolute;
            width: 1px;
            background: #8f8f94;
            right: 0;
            top: 20%;
            bottom: 20%;
        }

        .newPro {
            background: #f3f3f3;
        }

        /*公司信息弹出*/
        .myPicker {
            position: fixed;
            top: 45px;
            /*-webkit-transform: translateY(100%);*/
            right: 0;
            overflow: hidden;
            -webkit-transition: 1s;
            transition: 1s;
            width: 0;
            height: 0;
            color: #000;
            text-align: left;
            font-size: 14px;
            z-index: 9999;
        }

        .pickAnimate {
            /*-webkit-transform: translateY(-100px);*/
            width: 100%;
            height: 90px;
        }

        .myPicker .aui-iconfont {
            color: #000 !important;
            font-size: 20px !important;
        }

        .myPicker .aui-list-view-cell {
            overflow: hidden;
            padding: 5px 2px;
        }

        .myPicker .aui-list-view i.aui-iconfont {
            margin-right: 2px;
        }

        .myPicker .aui-list-view {
            background: #f3f3f3;
        }

        .myPicker .aui-list-view:after {
            top: 97%;
        }

        .bigPic .divPrice {
            color: #ec2e2e;
            font-weight: bold;
            text-align: left;
            padding-left: 10px !important;
            font-size: 14px;
        }

        .divPrice {
            float: left;
        }

        .bigPic .divBuy {
            text-align: right;
            padding-right: 10px !important;
            color: #327afa;
            /*font-weight: bold;*/
            font-size: 12px;
            float: right !important;
            color: #9c9c9c;
        }

        .proInfo .aui-img-body {
            height: 50px;
            padding: 5px !important;
        }

        .bigPic .divPrice, .divBuy {
            padding: 5px;
            overflow: hidden;
        }

        .bigPic .w50 {
            width: 50%;
            float: left;
        }

        .aui-ellipsis-2 {
            display: -webkit-box;
            overflow: hidden;
            text-overflow: ellipsis;
            word-wrap: break-word;
            white-space: normal !important;
            -webkit-line-clamp: 2;
            -webkit-box-orient: vertical;
        }

        .aui-list-view-cell {
            border-radius: 2px;
        }

        /*//一行两列样式*//**/
        .bigPic.aui-list-view.aui-grid-view {
            padding: 0 !important;
            background: #f3f3f3;
        }

        .bigPic.aui-list-view.aui-grid-view .aui-list-view-cell {
            padding: 0 !important;
        }

        .bigPic .aui-col-xs-6:nth-of-type(2n+1) {
            margin-right: 1%;
        }

        .bigPic.aui-list-view.aui-grid-view .aui-list-view-cell .aui-img-body {
            margin: 0 0 0 5px;
            margin-bottom: 1px;
            text-align: left;
        }

        .bigPic li {
            background: #fff !important;
            margin-bottom: 8px;
        }

        .bigPic .aui-col-xs-6 {
            width: 49.5%;
        }

        .bigPic .line {
            width: 90%;
            margin-left: 5%;
        }

        /*一行一列样式*/
        .smallPic .proPic {
            width: 100%;
        }

        .smallPic .divPrice {
            color: #ec2e2e;
            font-weight: bold;
            text-align: left;
            padding-left: 10px !important;
            font-size: 14px;
        }

        .smallPic .divBuy {
            text-align: right;
            padding-right: 10px !important;
            color: #9c9c9c;
            /*font-weight: bold;*/
            font-size: 12px;
            float: right !important;
        }

        .smallPic .divPrice {
            padding: 5px;
            /*padding-top:0px;*/
            overflow: hidden;
            position: absolute;
            bottom: 8px;
        }

        .smallPic .divBuy {
            padding: 5px;
            padding-left: 9px;
            overflow: hidden;
            position: absolute;
            bottom: 30px;
            color: #9c9c9c;
        }

        .smallPic .w50 {
            width: 100%;
            /*float: left;*/
            text-align: left !important;
            line-height: 1;
        }

        .smallPic.aui-list-view.aui-grid-view {
            padding: 0 !important;
            background: #f3f3f3;
        }

        .smallPic.aui-list-view.aui-grid-view .aui-list-view-cell {
            padding: 0 !important;
            padding: 8px !important;
        }

        .smallPic .proPic {
            width: 30%;
            float: left;
        }

        .smallPic .proInfo {
            width: 70%;
            float: left;
        }

        .smallPic .aui-border-b:after {
            border: none;
        }

        .smallPic .aui-col-xs-6:nth-of-type(2n+1) {
            margin-right: 0%;
        }

        .smallPic.aui-list-view.aui-grid-view .aui-list-view-cell .aui-img-body {
            margin: 0px 10px 0 10px;
            text-align: left;
        }

        .smallPic li {
            background: #fff !important;
            margin-bottom: 10px;
        }

        .smallPic .aui-col-xs-6 {
            width: 100%;
        }

        .contain {
            padding: 10px 0 0 0;
        }

        .bigPic0s {
            display: none !important;
        }

        .dongtai {
            display: none;
        }

        .dongtai ul {
            overflow-y: hidden;
        }

        .dongtai .aui-tab-nav li.active {
            color: #327afa;
            border-bottom: 2px #327afa solid;
        }

        .dongtai .divHeader {
            width: 40%;
            margin: 0 auto;
        }

        .dongtai ul {
            background: #f3f3f3;
        }

        .dongtai .aui-list-view .aui-img-object {
            max-width: 40px;
            height: 40px;
        }

        .dongtai .aui-list-view .aui-img-object.aui-pull-left {
            margin-right: 10px;
        }

        .dongtai .aui-list-view-cell {
            margin-bottom: 15px;
            background: #fff;
            margin-top: 8px;
        }

        .dongtai .aui-img-body {
            float: left;
            max-width: 195px;
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
        }

        .dongtai .remenType ul {
            background: #fff;
        }

        .dongtai .aui-list-view:after {
            border: none;
        }

        .dongtai .type {
            font-size: 12px;
            background: #feb77e;
            color: #fff;
            padding: 2px 5px;
        }

        .dongtai .title {
            width: 100%;
            display: inline-block;
            margin: 6px;
        }

        .dongtai .conttent img {
            width: 31%;
            margin-left: 2%;
            float: left;
            margin-top: 8px;
        }

        .type2 {
            font-size: 12px;
            color: #fff;
            padding: 2px 5px;
            background: #78D98E;
        }

        .mui-backdrop {
            position: fixed;
            top: 0;
            right: 0;
            bottom: 0;
            left: 0;
            z-index: 998;
            background-color: rgba(0, 0, 0, .3);
        }

        .smallPic .divBuy {
            padding: 5px;
            padding-left: 9px;
            overflow: hidden;
            position: absolute;
            bottom: 30px;
            float: right;
        }

        .smallPic .divBuy {
            text-align: right;
            padding-right: 10px !important;
            color: #9c9c9c;
            /* font-weight: bold; */
            font-size: 12px;
            float: right !important;
        }

        .aui-searchbar-text {
            background: #f4f3f3;
            height: 35px;
            line-height: 35px;
            color: #ccc;
            border-radius: 5px;
            text-align: left;
            padding-left: 32px;
        }

    </style>
</head>
<body>
<div class="allContain">
    <header class="aui-bar aui-bar-nav aui-border-b headerSearch">
        <div>
            <div class="aui-pull-left aui-iconfont aui-icon-left icon-left-coler" tapmode onclick="closeWin()"></div>
            <div class="divSeach" tapmode onclick="openToTwo('../search')">
                <i class="aui-iconfont aui-icon-search aui-pull-left"></i>
                <div class="aui-searchbar-text">请输入搜索内容</div>
            </div>
            <div class="headerRight">
                <i class="aui-iconfont aui-icon-message aui-pull-left" tapmode onclick="openToTwo('news')"></i>
                <i class="aui-iconfont aui-icon-more aui-pull-left" tapmode onclick="showPicker()"></i>
            </div>
        </div>
    </header>

    <div class="bigContain">
        <div class="bigWraper">
            <header class="aui-bar aui-bar-nav">
                <div class="my-info" id="Info-content"></div>
                <div class="aui-nav " id="headerFooter">
                    <ul class="aui-bar-tab">
                        <li class="active" id="tabbar1" data-type="1" data-order="3" data-module="index" tapmode
                            onclick="changeCheck(this)" >
                            <span class="aui-iconfont aui-icon-shop"></span>
                            <p>
                                店铺首页
                            </p>
                        </li>
                        <li id="tabbar2" data-type="2" data-order="1" data-module="all" tapmode
                            onclick="changeCheck(this)">
                            <span class="aui-iconfont aui-icon-sort"></span>
                            <p>
                                全部商品
                            </p>
                        </li>
                        <li id="tabbar3" data-type="3" data-order="2" data-module="new" tapmode
                            onclick="changeCheck(this)">
                            <span class="aui-iconfont ">NEW</span>
                            <p>
                                新品上架
                            </p>
                        </li>
                        <li id="tabbar4" data-type="4" data-module="activity" tapmode onclick="changeCheck(this)">
                            <span class="aui-iconfont aui-icon-read"></span>
                            <p>
                                店铺动态
                            </p>
                        </li>
                    </ul>
                </div>
                <ul class="aui-tab-nav aui-border-t allPro">
                    <li class="active" data-type="1" tapmode onclick="switchChange(this)">
                        综合
                    </li>
                    <li data-type="2" tapmode onclick="switchChange(this)">
                        新品
                    </li>
                    <li data-type="3" tapmode onclick="switchChange(this)">
                        销量
                    </li>
                    <li data-type="4" tapmode onclick="switchChange(this)">
                        价格
                    </li>
                    <li tapmode onclick="changeView(this)" view-type="bigPic">
                        <i class="aui-iconfont aui-icon-cascades icon-left-coler"></i>
                    </li>
                </ul>
                <div class="zfTitle indexPro  aui-border-b  aui-border-t">热销推荐<span
                        class="aui-pull-right more">更多</span>
                </div>
                <div class="zfTitle newInfo  aui-border-b  aui-border-t">最新动态</div>

            </header>
            <div class="proContain">
                <div class="wrapper">
                    <div class="aui-content-padded contain gongchang">
                        <div class="kongshuju">
                            <p>暂无数据</p>
                        </div>
                        <div class="prolist ">

                            <ul class="aui-list-view aui-grid-view bigPic" id="myMall-content">

                            </ul>

                        </div>
                        <div class="dongtai">
                            <ul class="aui-list-view" id="activity-content"></ul>
                        </div>
                    </div>


                </div>
            </div>
        </div>
    </div>
    <footer class="aui-nav" id="aui-footer">
        <ul class="aui-bar-tab">
            <li id="tabbar12" tapmode onclick="tomyType()">
                <p>
                    商品分类
                </p>
            </li>
            <li id="tabbar2" tapmode onclick="tocomIntrol()">
                <p>
                    公司介绍
                </p>
            </li>
        </ul>

    </footer>
</div>
<div class="myPicker">
    <ul class="aui-list-view">
        <li class="aui-list-view-cell" tapmode onclick="openToTwo('news')">
            <i class="aui-iconfont aui-icon-comment"></i><span>我的消息 </span>
        </li>
        <li class="aui-list-view-cell" tapmode onclick="goToHome(0)">
            <i class="aui-iconfont aui-icon-home"></i><span>首页</span>
        </li>
    </ul>
</div>
<script id="Info-template" type="text/x-dot-template">
    <div class="headerPic"><img src="{{=it.company.bgurl==''?'../../image/header.jpg':it.company.bgurl}}"></div>
    <div class="myInfoList">
        <ul>
            <li>
                <div class="touxiang">
                    <img src="{{=it.company.thumb}}" alt="">
                </div>
            </li>
            <li class="infoLeft ">
                <div class="companyName aui-ellipsis-1">{{=it.member.company}}</div>
                <span class="year">{{=it.member.regtime}}</span>
            </li>
            <li class="infoRight aui-pull-right">
                <div class="fensi">
                    <span class="num ">{{=it.company.collect}}</span>
                    <p style="color:#fff">粉丝数</p>
                </div>
                <div class="shoucang   aui-btn-info">收藏
                </div>
                <!--<div class="shoucang   aui-btn-info" {{? it.member.collect_style
                     !=0}}onclick="tocollect({{=it.member.userid}})"{{?}}>{{? it.member.collect_style == 0}}已{{?}}收藏
                </div>-->
            </li>
        </ul>
    </div>
</script>
<script id="myMall-template" type="text/x-dot-template">
    {{ for(var i in it){ }}
    <li class="aui-list-view-cell aui-img aui-col-xs-6"   tapmode onclick="goToPro2(this)" >
        <div class="proPic" ><img class="aui-img-object" src="{{=it[i].thumb}}" >
        </div>
        <div class="proInfo"  >
            <div class="aui-img-body  aui-ellipsis-2">
                {{=it[i].title}}
            </div>
            <div class="aui-border-b line"></div>
            <div class="divBuy  zfhuise">
                成交<span class="num">{{=it[i].sales}}</span>笔
            </div>
            <div class="divPrice  zfBlue" >
                ￥<span class="price ">{{=it[i].price}}</span>
            </div>
        </div>
    </li>
    {{ } }}
</script>
<script id="newMall-template" type="text/x-dot-template">
    {{ for(var i in it){ }}
    {{? it[i].length > 0}}
    <ul class="aui-list-view aui-grid-view">
        <p>近{{= i }}周上新</p>
        {{ for(var k in it[i]){ }}
        <li class="aui-list-view-cell aui-img aui-col-xs-6" tapmode onclick="goToPro2()">
            <div class="proPic"><img class="aui-img-object" src="{{=it[i][k].thumb}}">
            </div>
            <div class="proInfo">
                <div class="aui-img-body  aui-ellipsis-2">
                    {{=it[i][k].title}}
                </div>
                <div class="aui-border-b line"></div>
                <div class="divBuy  zfhuise">
                    成交<span class="num">{{=it[i][k].sales}}</span>笔
                </div>
                <div class="divPrice  zfBlue">
                    ￥<span class="price ">{{=it[i][k].price}}</span>
                </div>
            </div>
        </li>
        {{ } }}
    </ul>
    {{?}}
    {{ } }}
</script>
<script id="activity-template" type="text/x-dot-template">
    {{ for(var i in it){ }}
    <li class="aui-list-view-cell aui-img">
        <img class="aui-img-object aui-pull-left" src="{{=it[i].logo}}">
        <div class="aui-img-body">
            {{=it[i].company}}
            <p><span class="time">{{=it[i].addtime}}</span> 浏览<span class="sum">{{=it[i].hit}}</span></p>
        </div>
        {{? it[i].status == 1 }}
        <div class="type aui-pull-right">优惠</div>
        {{?? it[i].status == 2 }}
        <div class="type2 aui-pull-right">上新</div>
        {{?}}
        <div class="title">{{=it[i].title}}</div>
        <div class="conttent">
            <img src="{{=it[i].thumb}}">
            <img src="{{=it[i].thumb1}}">
            <img src="{{=it[i].thumb2}}">
        </div>
    </li>
    {{ } }}
</script>

</body>
<script type="text/javascript" src="../../script/api.js"></script>
<script type="text/javascript" src="../../script/doT.min.js"></script>
<script type="text/javascript" src="../../script/common.js"></script>
<script type="text/javascript" src="../../script/myInfo.js"></script>
<script type="text/javascript" src="../../script/iscroll2.js"></script>
<script type="text/javascript" src="../../script/jquery-1.11.3.js"></script>
<script type="text/javascript" src="../../script/mui.js"></script>
<script type="text/javascript">
    var username;
    var page = 1, type = 3, module = 'index', viewType = 'smallPic', isLock = false;
    apiready = function () {
        $(".allContain").hide();//加载完店铺信息在显示
        api.parseTapmode();
        companyid = api.pageParam.companyid;
        getInfo(companyid);//加载数据也放在里面
        mobile = api.pageParam.mobile;
        header = $api.dom('header');
        footer = $api.dom('footer');
        $api.fixIos7Bar(header);
        dataScroll();
        //getData();
        changeView(viewType);
//        setTimeout(function () {
//
//
//        }, 2000)
        //重新登录监听
        api.addEventListener({
            name: 'reGetMyInfo'
        }, function (ret) {
            if (ret && ret.value) {
                page = 1;
                getData();
            }
        });
        //监听是否达到底部上拉加载
        api.addEventListener({
            name: 'scrolltobottom'
        }, function (ret, err) {
            page++;
            if (isLock == false) {
                getData();
            }
        });
        //排列登录监听
        api.addEventListener({
            name: 'arrangeType'
        }, function (ret) {
            if (ret && ret.value) {
                viewType = ret.value.viewType;
                changeView(viewType);
            }
        });
        //一级分类监听
        api.addEventListener({
            name: "reGetMyType"
        }, function (ret) {
            if (ret && ret.value) {
                $("#activity-content").html("");
                $("#myMall-content").html("");
                typeid = ret.value.typeid;
                module = ret.value.module;

                getData(typeid);
            }
        })
        //二级分类监听
        api.addEventListener({
            name: "mallType"
        }, function (ret) {
            if (ret && ret.value) {
                typeid = ret.value.typeid;
                getData(typeid);
            }
        })

    }
    function showData(data) {
        if (data == "4") {
            $(".dongtai").css({"display": "block"});
            $(".prolist").css({"display": "none"});
        } else {
            $(".dongtai").css({"display": "none"});
            $(".prolist").css({"display": "block"});
        }

    }
    //跳转到商品
    var hhh = 0;
    function goToPro(itemid) {
//        path=path?path:'./';
        alert(hhh)
        api.openWin({
            name: 'proInfo_win',
            url: '../proInfo_win.html',
            pageParam: {
                itemid: itemid
            }
        });
        event.preventDefault();
        event.stopPropagation();
    }
    function goToPro2(obj) {
//        path=path?path:'./';
        alert($(obj).attr("class"))
//        api.openWin({
//            name: 'proInfo_win',
//            url: '../proInfo_win.html',
//            pageParam: {
//                itemid: itemid
//            }
//        });
//        event.preventDefault();
//        event.stopPropagation();
    }
    //    function changeView(viewType) {
    //        if (viewType == "bigPic") {
    //            //一行两列
    //            $(".prolist").find("ul").addClass("smallPic");
    //            $(".prolist").find("ul").removeClass(viewType);
    //            $(".aui-icon-cascades").addClass("iConent");
    //        } else if (viewType == "smallPic") {
    //            //一行一列
    //            $(".aui-icon-cascades").removeClass("iConent");
    //            $(".prolist").find("ul").addClass("bigPic");
    //            $(".prolist").find("ul").removeClass(viewType);
    //        }
    //    }

    function getData(typeid) {
        isLock = true;
        showLoading();
        var data = {};
        if (module == "activity") {
            var url = 'factory/getactivity';
        } else {
            var url = 'category/categoryList';
        }
        if (!typeid) {
            typeid = type;
        }
//        alert(typeid)
        data['page'] = page;
        data['username'] = username;
        data['pagetype'] = module;
        data['type'] = typeid;
        ajaxRequest(url, 'post', data, function (ret, err) {
            if (ret.status == 1) {
                $(".kongshuju").hide();
                var tpl;
                if (module == 'new') {
                    tpl = $api.byId('newMall-template').text;
                    ID = 'myMall-content';
                } else if (module == 'activity') {
                    tpl = $api.byId('activity-template').text;
                    ID = 'activity-content';
                } else {
                    tpl = $api.byId('myMall-template').text;
                    ID = 'myMall-content';
                }
                var content = $api.byId(ID);
                var tempFn = doT.template(tpl);
                if (page > 1) {
                    $api.append(content, tempFn(ret.msg));
                    isLock = false;
                } else {
                    $api.html(content, tempFn(ret.msg));
                    isLock = false;
                }

                api.toast({
                    msg: "数据加载成功！",
                    duration: 2000,
                    location: 'bottom'
                });
                myScroll.refresh();
                changeView(viewType);
                hideLoading();
            } else {

                if (page == 1) {
                    $(".kongshuju").show();
                }

                hideLoading();
                api.toast({
                    msg: ret.msg,
                    duration: 2000,
                    location: 'bottom'
                });
            }
        });
    }
    function tocollect(companyid) {
        $(".shoucang").unbind("click");
        showLoading();
        if (!user_id) {
            openTo('../loginPass_win');
            return;
        }
        var data = {};
        var url = 'factory/collect/userid/' + user_id + '/type/company/id/' + companyid;
        ;
        ajaxRequest(url, 'get', data, function (ret, err) {
            if (ret.msg == 1) {
                ret.msg = '收藏成功';
                getInfo(companyid);
//                $(".shoucang").text("已收藏")
                $(".shoucang").text("取消收藏").bind("click", function () {
                    collectionCancel(companyid)
                })
            }
            hideLoading();
            api.toast({
                msg: ret.msg,
                duration: 2000,
                location: 'bottom'
            });
        });
    }
    //取消收藏
    function collectionCancel(id) {

        $(".shoucang").unbind("click");
        showLoading();
        data = {
            userName: user_name,
            type: 2,
            id: id,
        };
        url = "User/collectionCancel";
        ajaxRequest(url, 'post', data, function (ret, err) {
            if (ret.status == 1) {
                //发送监听
                api.sendEvent({
                    name: 'collectionCancel',
                    extra: {
                        key: 'true'
                    }
                });
                $(".shoucang").text("收藏").unbind("click").bind("click", function () {
                    tocollect(id)
                })
                getInfo(companyid);
                api.toast({
                    msg: '取消成功',
                    duration: 2000,
                    location: 'bottom'
                });
            } else {
                api.toast({
                    msg: '取消失败',
                    duration: 2000,
                    location: 'bottom'
                });
            }
        });
        hideLoading();
    }
    function switchChange(obj) {
        $('.aui-tab-nav li').removeClass('active');
        $(obj).addClass('active');
        var type = $(obj).attr('data-type');
        page = 1;
        api.sendEvent({
            name: 'mallType',
            extra: {
                typeid: type
            }
        })
    }
    //为了在下面的热门类别可以通用，单独出来
    function changeCheck(obj) {
        $(obj).parent().find("li").removeClass("active");
        $(obj).addClass("active");
        page = 1;
        //显示热销或者15天前那些
        var dataType = $(obj).attr("data-type");
        var dataOrder = $(obj).attr("data-order");
        var dataModule = $(obj).attr("data-module");
        showData(dataType)
        //商品参数更新
        api.sendEvent({
            name: 'reGetMyType',
            extra: {
                typeid: dataOrder,
                module: dataModule
            }
        });
        switch (dataType) {
            case "1":
                $(".indexPro").css({"display": "block"});
                $(".allPro").css({"display": "none"});
                $(".newPro").css({"display": "none"});
                $(".newInfo").css({"display": "none"});
                break;
            case "2":
                $(".indexPro").css({"display": "none"});
                $(".allPro").css({"display": "-webkit-box"});
                $(".newPro").css({"display": "none"});
                $(".newInfo").css({"display": "none"});
                break;
            case "3":
                $(".indexPro").css({"display": "none"});
                $(".allPro").css({"display": "none"});
                $(".newPro").css({"display": "block"});
                $(".newInfo").css({"display": "none"});
                break;
            case "4":
                $(".indexPro").css({"display": "none"});
                $(".allPro").css({"display": "none"});
                $(".newPro").css({"display": "none"});
                $(".newInfo").css({"display": "block"});
                break;

        }
        //showHeader();
    }
    function changeView(obj) {
        var viewType = $(obj).attr("view-type");

        //排列参数更新
        api.sendEvent({
            name: 'arrangeType',
            extra: {
                viewType: viewType,
            }
        });

        if (viewType == "bigPic") {
            //一行两列
            $(".aui-icon-cascades").addClass("iConent");
            $(obj).attr("view-type", "smallPic");
            //一行两列
            $(".prolist").find("ul").addClass("smallPic");
            $(".prolist").find("ul").removeClass(viewType);
            $(".aui-icon-cascades").addClass("iConent");
        } else if (viewType == "smallPic") {
            //一行一列
            $(".aui-icon-cascades").removeClass("iConent");
            $(obj).attr("view-type", "bigPic");
            //一行一列
            $(".aui-icon-cascades").removeClass("iConent");
            $(".prolist").find("ul").addClass("bigPic");
            $(".prolist").find("ul").removeClass(viewType);
        }
    }
    function showHeader() {
        header_h = $api.offset(header).h;
        footer_h = $api.offset(footer).h;
        body_h = $api.offset($api.dom('body')).h - header_h - footer_h;
        api.openFrame({
            name: 'myShop_frm',
            url: 'myShop_frm.html',
            rect: {
                x: 0,
                y: header_h,
                w: 'auto',
                h: body_h
            },
            pageParam: {
                username: username
            },
            bounces: false,
            vScrollBarEnabled: false,
            hScrollBarEnabled: false
        });
    }

    function getInfo(companyid) {
        showLoading();
        getStorageAll();
        var data = {};
        if (!user_id) {
            var url = 'factory/getinfo/companyid/' + companyid;
        } else {
            var url = 'factory/getinfo/companyid/' + companyid + '/userid/' + user_id;
        }
        ajaxRequest(url, 'get', data, function (ret, err) {
//             alert(JSON.stringify(ret.msg));
            if (ret.status == 1) {
                username = ret.msg.member.username
                var content = $api.byId('Info-content');
                var tpl = $api.byId('Info-template').text;
                var tempFn = doT.template(tpl);
                $api.html(content, tempFn(ret.msg));

                if (ret.msg.member.collect_style != 0) {
                    $(".shoucang").unbind("click").bind("click", function () {
                        tocollect(ret.msg.member.userid)
                    })
                } else {
                    $(".shoucang").text("取消收藏").unbind("click").bind("click", function () {
                        collectionCancel(ret.msg.member.userid)
                    })
                }
                //showHeader();
//                hideLoading();

                $(".allContain").show();
                getData();
            } else {
                hideLoading();
                api.toast({
                    msg: ret.msg,
                    duration: 2000,
                    location: 'bottom'
                });
            }
        });
    }

    function tocomIntrol() {
        api.openWin({
            name: 'comIntrol_win',
            url: 'comIntrol_win.html',
            pageParam: {
                companyid: companyid
            },
            //delay: 300
        });
    }

    function tomyType() {
        api.openWin({
            name: 'myType_win',
            url: 'myType_win.html',
            pageParam: {
                companyid: companyid
            },
            //delay: 300
        });
    }
    // mui遮罩
    var mask;
    // 显示遮罩
    function showPicker() {
        $(".myPicker").addClass("pickAnimate");
        mask = mui.createMask(hidePicker);
        mask.show();
        //跨域执行子frame的显示mask
        api.execScript({
            frameName: "myShop_frm",
            script: "showMask()"
        })
    }
    // 关闭遮罩
    function hidePicker() {
        $(".myPicker").removeClass("pickAnimate");
        //跨域执行子frame的关闭mask
        api.execScript({
            frameName: "myShop_frm",
            script: "hideFrmMask()"
        })
    }
    //接收子frm执行的关闭遮罩
    function closeWinMask() {
        $(".myPicker").removeClass("pickAnimate");
        mask.myclose();
        //hidePicker();
    }

    //后加的
    function dataScroll() {

        $(".bigContain").height($("body").height() - $(".headerSearch").height() - $("footer").height());
        $(".proContain").height($("body").height() - $(".headerSearch").height() - $("footer").height() - 100);
        //alert($("body").height() - $(".headerSearch").height() - $("footer").height() - 120)
        myBigScroll = new IScroll(".bigContain", {
            probeType: 3,
            click: true,
            bounce: false
        })
        myScroll = new IScroll(".proContain", {
            probeType: 3,
            click: true
        })

        myBigScroll.on("scrollEnd", function () {
            //首先为了获取的滚动最大的值，因为刚好是要滚动隐藏130px的高度，所以maxScrollY就是130px
            //而第二层设置了高度为samllH,所以bigH的高度为smallH+头部高度（本例子是230）
            if (myBigScroll.y == myBigScroll.maxScrollY) {
                myBigScroll.disable();
            }
        });
        myScroll.on("scrollEnd", function () {
            if (Math.abs(myScroll.y) <= 10) {
                myBigScroll.enable();
            }
        })
//        下拉刷新
        scroll();
    }

    function scroll() {
        var upIcon = $(".downIcon"),
            downIcon = $(".upIcon");
        myScroll.on("scroll", function () {
            var y = this.y,
                maxY = this.maxScrollY - y,
                downHasClass = downIcon.hasClass("reverse_icon"),
                upHasClass = upIcon.hasClass("reverse_icon");
//            if (y >= 40 && !downHasClass) {
//                $(".downIcon").addClass("turnUp");
//                downIcon.addClass("reverse_icon");
//                $(".pull-down-msg").text("松手刷新");
//                return "";
//            } else if (y < 5 && downHasClass) {
//                $(".downIcon").removeClass("turnUp");
//                downIcon.removeClass("reverse_icon");
//                $(".pull-down-msg").text("下拉刷新");
//                return "";
//            }

            if (maxY >= 40 && !upHasClass) {
                $(".upIcon").addClass("turnDown");
                upIcon.addClass("reverse_icon");
                $(".pull-up-msg").text("松手刷新");
                return "";
            } else if (maxY < 5 && upHasClass) {
                $(".upIcon").removeClass("turnDown");
                upIcon.removeClass("reverse_icon");
                $(".pull-up-msg").text("上拉刷新");
                return "";
            }
        });

        myScroll.on("slideDown", function () {
            //下拉刷新
            if (this.y > 40) {
                //添加数据

                page++;
                if (isLock == false) {
                    getData();
                }

                myScroll.refresh();
            }
        });

//        myScroll.on("slideUp", function () {
//            //上拉刷新
//            if (this.maxScrollY - this.y > 40) {
//                //添加数据
//
//                page++;
//                if (isLock == false) {
//                    getData();
//                }
//                myScroll.refresh();
//            }
//        });

    }
</script>
</html>
